import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
 * @作者: xiaoxun
 * @日期: 2025/3/9 14:50
 * @描述: 房间
 */
public class Room {
	//1、准备一副牌
	private ArrayList<Card> allCard=new ArrayList<>();
	//2、初始化54张牌
	{
//		3、准备点数
		String[] numbers={"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
		String[] colors={"♥","♠","♣","♦"};
		int size=0;
		for (String number:numbers){
			size++;
			for (String color:colors){
				Card c=new Card(number,color,size);
				allCard.add(c);
			}
		}
		//4、添加大小王
		allCard.add(new Card("","\uD83D\uDC12",++size));
		allCard.add(new Card("","\uD83E\uDD21",++size));
		System.out.println("新牌是："+allCard);
	}
	public void start(){
		//2、洗牌
		Collections.shuffle(allCard);
		//3、发牌
			//定义三个玩家
		List<Card> yi=new ArrayList<>();
		List<Card> er=new ArrayList<>();
		List<Card> san=new ArrayList<>();
		for (int i = 0; i < allCard.size()-3; i++) {
			Card c=allCard.get(i);
			if(i%3==0){
				yi.add(c);
			} else if (i%3==1) {
				er.add(c);
			} else if (i%3==2) {
				san.add(c);
			}
		}
		//拿到地主牌
		List<Card> last=allCard.subList(allCard.size()-3,allCard.size());
		//抢地主
		er.addAll(last);
		//4、对牌进行排序
		sortCards(yi);
		sortCards(er);
		sortCards(san);
		//看牌
		System.out.println("一："+yi);
		System.out.println("二："+er);
		System.out.println("三："+san);
	}
	public void sortCards(List<Card> cards){
		//排序方法
		Collections.sort(cards, new Comparator<Card>() {
			@Override
			public int compare(Card o1, Card o2) {
				return o1.getSize()- o2.getSize();
			}
		});
	}
}
